import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
    state: () => ({
        user: "test",
        password: "password",
        pass: false,
    }),
    getters: {
        isPass: (state) => state.pass,
    },
    actions: {
        check(user, password) {
            if (user === this.user && password === this.password){
                this.pass = true;
                return true;
            }else {
                this.pass = false;
                return false;
            }

        },
        reset() {
            this.user = null;
            this.password = null;
            this.pass = false;
        },
        register(user, password) {
            if(user===this.user ){
                return "User already exists";
            }
            this.user = user;
            this.password = password;
        },
    },
});